//PayXindaluOrderModel
//2021-07-19 13:05:52

package models

import (
	"git.900sui.cn/kc/base/common/functions"
	"git.900sui.cn/kc/base/common/models/base"
	"git.900sui.cn/kc/kcgin/orm"
)

const StatusSuccess = "1"
const StatusError = "2"

//表结构体
type PayXindaluOrderModel struct {
	Model *base.Model
	Field PayXindaluOrderModelField
}

//表字段
type PayXindaluOrderModelField struct {
	T_table             string `default:"pay_xindalu_order"`
	F_id                string `default:"id"`
	F_order_sn          string `default:"order_sn"`
	F_xindalu_order_sn  string `default:"xindalu_order_sn"`
	F_created_at        string `default:"created_at"`
	F_uoin_order_params string `default:"uoin_order_params"`
	F_starus            string `default:"starus"`
}

//初始化
func (p *PayXindaluOrderModel) Init(ormer ...orm.Ormer) *PayXindaluOrderModel {
	functions.ReflectModel(&p.Field)
	p.Model = base.NewModel(p.Field.T_table, ormer...)
	return p
}

//新增数据
func (p *PayXindaluOrderModel) Insert(data map[string]interface{}) int {
	result, _ := p.Model.Data(data).Insert()
	return result
}
func (p *PayXindaluOrderModel) SelectOrderSnByXinOrderSn(xindalu_order_sn string) (map[string]interface{}, error) {
	result := p.Model.Field([]string{p.Field.F_order_sn}).
		Where(map[string]interface{}{p.Field.F_xindalu_order_sn: xindalu_order_sn}).
		Find()
	return result, nil
}
